import phoneCodesData from './phone-codes.json';

export interface PhoneCode {
  name: string;
  name_zh: string;
  name_vi: string;
  code: string;
  flag: string;
}

export const phoneCodes: PhoneCode[] = phoneCodesData;

export const getCountryName = (phoneCode: PhoneCode, locale: string): string => {
  switch (locale) {
    case 'zh':
      return phoneCode.name_zh;
    case 'vi':
      return phoneCode.name_vi;
    default:
      return phoneCode.name_zh; // 默认返回中文
  }
};

export const getPhoneCodesWithLocalizedNames = (locale: string) => {
  return phoneCodes.map(code => ({
    ...code,
    displayName: getCountryName(code, locale)
  }));
};
